package it.koutifaris.travianmap.geometry;

public class DistanceCalculator {

	private final Point origin;
	private final Point destination;

	public DistanceCalculator(Point origin, Point destination) {
		this.origin = origin;
		this.destination = destination;
	}

	public float getDistance() {
		return (float) distance(origin.getX(), origin.getY(), destination.getX(), destination.getY());
	}

	public float getTime(float speed) {
		return getDistance() / speed;
	}

	private double distance(int x0, int y0, int x1, int y1) {
		return Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
	}

}
